//var getIp = 'http://4scafe.carnettong.com';// 双胜
var getIp = 'http://carnt.carnettong.com:8088';// 线上
//var getIp = 'http://192.168.0.180';
var rollFlag = false;
// ----------------------------------------------------------------- 获取DOM
var maskBg = $('.mask'),
        yoooClose = $('.close'), // 关闭弹窗
        ruleAlert = $('#activeRule'), // 查看规则
        rulesMain = $('.drawRulePages'), // 规则
        verification = $('.verification'), // 登录界面
        phone_number = $('.phone_number input'), //手机input
        phone_code_get = $('.phone_code_get'), // 获取验证码按钮
        phone_code = $('.phone_code input'), // 验证玛 input
        toLogin = $('.toLogin'), // 提交
        codeKey = true, // 是否可以发送验证码
        canntDraw = $('.canntDraw'), // 抽奖机会用完的弹窗
        iKnow = $('.iKnow'), // 抽奖机会用完知道了按钮
        zhongBox = $('.zhongBox'),
        zhongRecord = $('.zhongRecord'),
        CDtimer = null //倒计时定时器
// 控制下载条在app不显示
if (_Global_ == 'app') {
    $('.lim').hide();
} else {
    $('.lim').show();
}
$('.closeLogo').on('click', function () {
    $('.lim').hide();
})
/* 弹出提示方法 */
function promptBox(text1, text2, func) {
    var promptB = $('.promptBox');
    promptB.find('.firstary').text(text1);
    if (text2) {
        promptB.find('.secondary').text(text2);
    }
    promptB.show();
    $('.mask').show();
    promptB.find('.iKnow').on('click', function () {
        promptB.hide();
        $('.mask').hide();
        func && func();
    })
}
function promptBox1(text1, text2, func) {
    var promptB = $('.promptBox1');
    promptB.find('.firstary1').text(text1);
    if (text2) {
        promptB.find('.secondary1').text(text2);
    }
    promptB.show();
    $('.mask').show();
    promptB.find('.iKnow1').on('click', function () {
        drawGo('http://carnt.carnettong.com:8088/4SCAFE/HTML5/aTestWx/dist/index.html');
        $('.mask').hide();
        $('.promptBox1').hide();
    })
}

// 是否在微信环境下
var is_WX = (function () {
    var ua = navigator.userAgent.toLowerCase();
    if (ua.match(/MicroMessenger/i) == "micromessenger") {
        return true;
    } else {
        return false;
    }
})()
//顶部
$(window).on("scroll", function () {
    var scrollTop = $("body").scrollTop();
    //当滚动超过1500px，显示回顶部按钮
    if (scrollTop > 1500) {
        $("#gotop").show();
    } else {
        $("#gotop").hide();
    }
})
$("#gotop").on("click", function () {
    $("body,html").scrollTop(0);
})
// tabs切换
$('.showTabs').on('click', function () {
    var scrollTop = $("body").scrollTop();
    //当大于两者高度就让导航悬浮，否则就固定在哪
    var heights = $(".pageTop").height();
    //控制显示那个导航
    if ($(this).hasClass('active')) {
        $('.showTabs').removeClass('active');
        $('.Items').hide();
        if (is_WX) {
            if (scrollTop > heights) {
                $(".pageNav").addClass("pageNavActiveItem");
                $(".pageNav").removeClass("pageNavActiveItems");
            } else {
                $(".pageNav").removeClass("pageNavActiveItems");
                $(".pageNav").removeClass("pageNavActiveItem");
            }
        }
    } else {
        $('.showTabs').addClass('active');
        $('.Items').show();
        if (scrollTop > heights) {
            $(".pageNav").addClass("pageNavActiveItems");
            $(".pageNav").removeClass("pageNavActiveItem");
        } else {
            $(".pageNav").removeClass("pageNavActiveItems");
            $(".pageNav").removeClass("pageNavActiveItem");
        }
    }
})

//顶部导航位置的设置
$(window).on("scroll", function () {
    var scrollTop = $("body").scrollTop();
    //当大于两者高度就让导航悬浮，否则就固定在哪
    var heights = $(".headerImg").height();
    //控制显示那个导航
    var h1 = heights + $(".contentMain").height() + $(".safetyHammer").height();
    var h2 = $('.safetyHammer').offset().top;
    var h3 = $('.bargainCarp').offset().top;
    if (is_WX) {
        if (scrollTop > heights) {
            if ($('.showTabs').hasClass('active')) {
                $(".pageNav").addClass("pageNavActiveItems");
            } else {
                $(".pageNav").addClass("pageNavActiveItem");
                $(".pageNav").removeClass("pageNavActiveItems");
            }
        } else {
            $(".pageNav").removeClass("pageNavActiveItems");
            $(".pageNav").removeClass("pageNavActiveItem");
        }
    } else {
        if (scrollTop > heights) {
            $(".pageNav").addClass("pageNavActive");
        } else {
            $(".pageNav").removeClass("pageNavActive");
        }
    }

    if (scrollTop < h1) {
        $(".pageNav a:eq(0)").addClass("active");
        $(".pageNav a:eq(1)").removeClass("active");
        $(".pageNav a:eq(2)").removeClass("active");
    } else {
        $(".pageNav a:eq(0)").removeClass("active");
    }
    if (scrollTop > h2) {
        $(".pageNav a:eq(1)").addClass("active");
        $(".pageNav a:eq(0)").removeClass("active");
        $(".pageNav a:eq(2)").removeClass("active");
    } else {
        $(".pageNav a:eq(1)").removeClass("active");
    }
    if (scrollTop > h3) {
        $(".pageNav a:eq(2)").addClass("active");
        $(".pageNav a:eq(0)").removeClass("active");
        $(".pageNav a:eq(1)").removeClass("active");
    } else {
        $(".pageNav a:eq(2)").removeClass("active");
    }
})

// 在微信先显示头部的tabs
if (is_WX) {
    $('.tabs').show();
    $(".headerBlank").css('display', 'block');
} else {
    $('.tabs').hide();
}
// ----------------------------------------------------------------- 自动生成中奖信息
function setDrawMess() {
    var parentUl = $(".allMess ul");
    var html = "";
    var arr = ["135", "177", "182", "152", "132", "139", "187", "153", "137", "187", "175", "155", "134", "188", "137"];
    var product = ["海灵车展门票", "50元保养劵", "50元喷漆劵", "10元咖啡劵", "30元车品券", "咖啡券5折", "5元鹿皮巾", "10元咖啡劵", "30元车品券", "咖啡券5折", "5元鹿皮巾"]
    for (var i = 0; i < 15; i++) {
        var num = parseInt(Math.random() * 10);
        var cardNum = parseInt(Math.random() * 11);
        var str = "";
        for (var j = 0; j < 4; j++) {
            str += parseInt(Math.random() * 10)
        }
        html += "<li>" + "恭喜" + arr[num] + "****" + str + "获得" + product[cardNum] + "</li>"
    }
    for (var k = 0; k < 2; k++) {
        parentUl.append(html);
    }
}
setDrawMess();
//中奖信息轮播
var index = 0;
var totoLength;
function moveDrawMess() {
    var childLi = $(".allMess ul").find("li"); // 所有 LI
    var childHeight = $(".allMess ul li").eq(1).height();
    totoLength = childLi.length;
    index++;
    var nowY = -(childHeight * index);
    $(".allMess ul")[0].style.transform = 'translateY(' + nowY + 'px)';
    if (index != 0) {
        $(".allMess ul")[0].style.transition = 'all 0.8s';
    }
    if (index > totoLength / 2) {
        $(".allMess ul")[0].style.transition = '';
        index = 0;
        $(".allMess ul")[0].style.transform = 'translateY(0px)';
    }
}
setInterval(moveDrawMess, 2000);
//加载更多
$(".loadmore").click(function () {
    $(".loadmore").hide();
    $(".drivingRecorderList3,.drivingRecorderList4").css('display', 'flex');
})
$(".loadmore2").click(function () {
    $(".loadmore2").hide();
    $(".safeSeatList3,.safeSeatList4").css('display', 'flex');
})

// ----------------------------------------------------------------- 转盘抽奖

var lottery = {
    index: -1, //当前转动到哪个位置，起点位置
    count: 0, //总共有多少个位置
    timer: 0, //setTimeout的ID，用clearTimeout清除
    speed: 20, //初始转动速度
    times: 0, //转动次数
    cycle: 50, //转动基本次数：即至少需要转动多少次再进入抽奖环节
    prize: 0, //中奖位置
    init: function (id) {
        if ($("#" + id).find(".lottery-unit").length > 0) {
            $lottery = $("#" + id);
            $units = $lottery.find(".lottery-unit");
            this.obj = $lottery;
            this.count = $units.length;
            $lottery.find(".lottery-unit-" + this.index).addClass("activeDraw");
        }
    },
    roll: function () {
        var index = this.index;
        var count = this.count;
        var lottery = this.obj;
        $(lottery).find(".lottery-unit-" + index).removeClass("activeDraw");
        index += 1;
        if (index > count - 1) {
            index = 0;
        }
        $(lottery).find(".lottery-unit-" + index).addClass("activeDraw");
        this.index = index;
        return false;
    },
    stop: function (index) {
        this.prize = index;
        return false;
    }
};

function roll() {
    lottery.times += 1;
    lottery.roll();
    var prize_site = $("#lottery").attr("prize_site");
    if (lottery.times > lottery.cycle + 10 && lottery.index == prize_site) {
        var prize_id = $("#lottery").attr("prize_id"); // 0 1 2 3 4 5 6 7 

        var prize_name = $("#lottery").attr("prize_name");
        //alert("前端中奖位置："+prize_site+"\n"+"中奖名称："+prize_name+"\n中奖id："+prize_id)
        //显示中奖的商品
        // 后台拿到中奖的id(0-6)  放在eq()中来显示转到的产品
        // 延迟显示，不让用户认为自己抽到的是上一个奖品			
        setTimeout(function () {
            $(".mask").show();
            $(".drawResult").show();//显示大盒子
            //alert('result'+prize_id);								
            $(".drawResult .result" + prize_id).siblings().hide();// 隐藏其它中奖结果
            $(".drawResult .result" + prize_id).show();// 显示中奖结果
            yaoFlag = true;
        }, 1000)


        clearTimeout(lottery.timer);
        lottery.prize = -1;
        lottery.times = 0;
        click = false;

    } else {
        if (lottery.times < lottery.cycle) {
            lottery.speed -= 10;
        } else if (lottery.times == lottery.cycle) {
            var index = Math.random() * (lottery.count) | 0;
            //console.log(index);
            lottery.prize = index;
        } else {
            if (lottery.times > lottery.cycle + 10 && ((lottery.prize == 0 && lottery.index == 7) || lottery.prize == lottery.index + 1)) {
                lottery.speed += 110;
            } else {
                lottery.speed += 20;
            }
        }
        if (lottery.speed < 40) {
            lottery.speed = 40;
        }
        lottery.timer = setTimeout(roll, lottery.speed);
    }
    return false;
}

var click = false;
lottery.init('lottery');//初始化转盘

// ----------------------------------------------------------------- 开始抽奖 (App以<%=fromPhone%>为参数)
$("#startDraw").click(function () {
    rollFlag = true;
    // 验证公共登录
    if (!commonSignIn())
        return;
    // 2.判断是否有抽奖机会 // 3.转盘操作
    $.ajax({
        url: getIp + '/CARNT/loli/haiLinLolitaAct',
        type: "post",
        dataType: "json",
        data: {
            PHONE: _Global_ == 'web' ? getCookie('userName') : phone
        },
        success: function (data) {
            console.log(data);
            if (data.STATUS_CODE == 1) {// 正常返回 可以抽奖				
                iCanDraw(data.PRIZE_SITE, data.PRIZE_ID);// 启动转盘          			     			
            } else if (data.STATUS_CODE == 2) {// 抽奖机会已用完
                promptBox('您已参与过本次活动', '分享记录可追加一次抽奖');
                maskBg.show();
            } else if (data.STATUS_CODE == 3) {
                promptBox('您的抽奖机会已经用完', ' ');
            } else if (data.STATUS_CODE == 15) {
                promptBox('缺少参数', ' ');
            } else {
                alert('服务器有异常');
            }
        }
    });
    // 抽奖函数
    function iCanDraw(prize_site, prize_id) {
        if (click) {
            return false;
        } else {
            lottery.speed = 100;
            // 位置和id组合是（后台返回）
            // 0-0,表示中了30元车品券
            // 2-2,表示中了50元保养券
            // 3-3,表示中了50元喷漆券
            // 4-4,表示中了10元咖啡券
            // 5-5,表示中了门票
            // 5-1,表示中了门票
            // 6-6,表示中了5折咖啡券
            // 7-7,表示中了5元鹿皮巾		        
            $("#lottery").attr("prize_site", prize_site);//中奖位置
            $("#lottery").attr("prize_id", prize_id); //中奖id
            roll();
            click = true;
            return;
        }
    }


});
// ----------------------------------------------------------------- 中奖后的跳转


function drawGo(str) {
    // 网页端跳转
    if (_Global_ == 'web') {
        if (!isNaN(str)) {
            if (str == 0) {//门票
                location.href = "http://carnt.carnettong.com:8088/CARNT/jsp/pay/indexM.html#/order/0";
            } else if (str == 1) {//5元鹿皮巾

            }

        } else {
            location.href = str;
        }
    }
    //app端跳转
    else {
        switch (str) {
            case 'http://carnt.carnettong.com:8088/CARNT/H5/carshop.jsp':// 车品
                openCarShop();
                break;
            case 'http://carnt.carnettong.com:8088/CARNT/jsp/maintain/choseCar.jsp?bro=m': // 保养
                sendAppRedirect('maintain');
                break;
            case 'http://carnt.carnettong.com:8088/CARNT//jsp/new_spray/index.html#/': // 喷漆
                sendAppRedirect('spray');
                break;
            case 0: 	// 门票
                orderList('2');  //待服务订单列表
                break;
            case 'http://carnt.carnettong.com:8088/4SCAFE/HTML5/aTestWx/dist/index.html': 	// 咖啡券
                sendAppRedirect('4scafe');
                break;
            case 'http://carnt.carnettong.com:8088/CARNT/jsp/pay/indexM.html#/carProduct': 	// 
                openCarShop();
                break;
            default:
                break;
        }
    }
}

// ----------------------------------------------------------------- 查看中奖记录，(App以<%=fromPhone%>为参数) 未登录需要先登录
$("#drawJ").on("click", function () {

    // 验证公共登录
    if (!commonSignIn())
        return;

    // 拿用户奖品记录
    $.ajax({
        url: getIp + '/CARNT/loli/getCommonLotteryRecord',
        type: "post",
        dataType: "json",
        data: {
            PHONE: _Global_ == 'web' ? getCookie('userName') : phone,
            ACTID: 20171115
        },
        success: function (data) {
            data.RESULT_DATA = data.RESULT_DATA.slice(0, 2);	//由于页面限制,只显示前两条	               
            // 正常返回
            $(".allRecord").html('');// 拼字符串前先清空
            if (data.STATUS_CODE == '1') {
                var doc = '';
                maskBg.show();
                if (data.RESULT_DATA.length == 0) {
                    $('.youHaveNot').show();
                    return;
                }
                for (var i = 0; i < data.RESULT_DATA.length; i++) {
                    if (data.RESULT_DATA[i].STATUS == '1') {// 未领取状态
                        switch (data.RESULT_DATA[i].PRIZE_ID) {
                            case 0://30元车品券
                                doc += '<div class="record0"><img src="images/show/jp1-1.png" onclick="drawGo(' + "'http://carnt.carnettong.com:8088/CARNT/jsp/pay/indexM.html#/carProduct'" + ')">\</div>';
                                break;
                            case 1://门票
                                doc += '<div class="record1" id="record2" style="display: block;"><img src="images/show/jp1-2.png" onclick="drawGo(0)"></div>';
                                break;
                            case 2://50元保养券
                                doc += '<div class="record2" style="display: block;"><img src="images/show/jp1-3.png" onclick="openMaintain()"></div>';
                                break;
                            case 4://10元咖啡券
                                doc += '<div class="record3" style="display: block;"><img src="images/show/jp1-5.png" onclick="drawGo(' + "'http://carnt.carnettong.com:8088/4SCAFE/HTML5/aTestWx/dist/index.html'" + ')">\</div>';//正式
                                //doc += '<div class="record3" style="display: block;"><img src="images/show/jp1-5.png" onclick="drawGo('+"'http://4scafe.carnettong.com/4SCAFE/HTML5/aTestWx/dist/index.html'"+')">\</div>';//测试
                                break;
                            case 7://5元鹿皮巾
                                doc += '<div class="record4" id="record8" style="display: block;"><img src="images/show/jp1-7.png" onclick="H5AppOpen(569433)"></div>';
                                break;
                            case 5://门票
                                doc += '<div class="record1" id="record2" style="display: block;"><img src="images/show/jp1-2.png" onclick="drawGo(0)"></div>';
                                break;
                            case 6://5折咖啡券
                                doc += '<div class="record6" style="display: block;"><img src="images/show/jp1-6.png" onclick="drawGo(' + "'http://carnt.carnettong.com:8088/4SCAFE/HTML5/aTestWx/dist/index.html'" + ')">\</div>';//正式
                                //doc += '<div class="record6" style="display: block;"><img src="images/show/jp1-6.png" onclick="drawGo('+"'http://4scafe.carnettong.com/4SCAFE/HTML5/aTestWx/dist/index.html'"+')">\</div>';//测试
                                break;
                            case 3://50元喷漆券
                                doc += '<div class="record7" id="record4" style="display: block;"><img src="images/show/jp1-4.png" onclick="openSpray()"></div>'
                                break;
                        }
                    } else if (data.RESULT_DATA[i].STATUS == '2') {//已经领取状态

                        switch (data.RESULT_DATA[i].PRIZE_ID) {
                            case 0:
                                doc += '<div class="record0"><img src="images/show/jp2-1.png"></div>';
                                break;
                            case 1:
                                doc += '<div class="record1" id="record2" style="display: block;"><img src="images/show/jp2-2.png"></div>';
                                break;
                            case 2:
                                doc += '<div class="record2" style="display: block;"><img src="images/show/jp2-3.png"></div>';
                                break;
                            case 3:
                                doc += '<div class="record3" style="display: block;"><img src="images/show/jp2-5.png"></div>';
                                break;
                            case 4:
                                doc += '<div class="record4" id="record8" style="display: block;"><img src="images/show/jp2-7.png"></div>';
                                break;
                            case 5:
                                doc += '<div class="record1" id="record2" style="display: block;"><img src="images/show/jp2-2.png"></div>';
                                break;
                            case 6:
                                doc += '<div class="record6" style="display: block;"><img src="images/show/jp2-6.png"></div>';
                                break;
                            case 7:
                                doc += '<div class="record7" id="record4" style="display: block;"><img src="images/show/jp2-4.png"></div>'
                                break;
                        }
                    }
                }

                $(".allRecord").html(doc);
                $(".drawRecord").show();
            } else {
                // 失败
                alert(data.RESULT_MSG);
            }

        }
    });

    // 这里eq()中的id同样是要去后台拿用户获得的奖品id
    //$(".drawRecord .allRecord div").hide("div");//隐藏所有的中奖记录模板
})
// ----------------------------------------------------------------- 中奖记录中产品点击弹出的弹窗
$("#record2").on("click", function () {
    alert(1);
    $(".recordDetail").show();
    $(".drawRecord").hide();
    $(".detail1").show().siblings("div").hide();
})
$("#record4").on("click", function () {
    $(".recordDetail").show();
    $(".drawRecord").hide();
    $(".detail2").show().siblings("div").hide();
})
$("#record8").on("click", function () {
    $(".recordDetail").show();
    $(".drawRecord").hide();
    $(".detail3").show().siblings("div").hide();
})
// 关闭弹出的门票，蜡扫，安全锁领取弹窗
$(".recordDetail span").on("click", function () {
    $(".recordDetail").hide();
    $(".maskBg").hide();
    $(".drawResult>div").hide();
    allClose();
})
// ----------------------------------------------------------------- 重写所有弹框关闭操作
function allClose() {
    maskBg.hide(); //关闭遮罩层
    rulesMain.hide(); //关闭规则弹框
    verification.hide();  //关闭登录框
    $(".drawResult").hide(); //关闭中奖结果
    $(".drawRecord").hide(); //中奖弹窗记录关闭
    $(".recordDetail").hide(); //关闭中奖详记录后的弹窗	
    canntDraw.hide(); // 关闭无抽奖次数通知
    $('.youHaveNot').hide();
    $('.noActive').hide();
}
// ------------------------------------------------------------------------------------ App - Web公共登录部分
function commonSignIn() {
    // 1.判断登录
    if (_Global_ == 'web') {
        // H5未登录
        if (!iLogin()) {
            alertVerification();
            return false;
        }
    } else if (_Global_ == 'app') {
        // app未登录
        if (phone == null || phone == 'null' || phone == '') {
            signIn();// app的登录
            return false;
        }
    }
    return true;
}
//手机正则
function isPhoneNumber(nub) {
    var myreg = /^1[34578]\d{9}$/;
    if (!myreg.test(nub)) {
        return false;
    }
    return true;
}
// ----------------------------------------------------------------- 倒计时
var CDtimer = null //倒计时定时器
function countDown() {
    var count = 60;
    CDtimer = setInterval(function () {
        if (count > 0) {
            count--;
            phone_code_get.html(count + 's后可重发');
        } else {
            clearInterval(CDtimer);
            phone_code_get.html('获取验证码');
            codeKey = true;
        }
    }, 1000)
}
// ----------------------------------------------------------------- 验证码发送
function sendMsgCode(phone) {
    $.ajax({
        url: getIp + '/CARNT/loli/sendVerifyCode',
        type: "post",
        dataType: "json",
        data: {
            PHONE: phone
        },
        success: function (data) {
            if (data.STATUS_CODE == 1) {// 正常返回
                codeKey = false;// 改变状态为false 不可再发送验证码
                countDown();//开始倒计时
            } else {
                alert('请重新获取');
            }
        }
    });
}
// ----------------------------------------------------------------- 获取验证码
phone_code_get.on('click', function () {
    var p = phone_number.val();   //电话号码		
    if (p == '') {
        $('.alertWord').text('手机号码不能为空').show();
        return;
    }
    if (isPhoneNumber(p)) {// 通过手机号码格式验证	
        if (codeKey) {
            sendMsgCode(p);// 发送验证码
        }
    } else {
        $('.alertWord').text('手机号码有误').show();
        return;
    }
});
// ----------------------------------------------------------------- 去登陆	
toLogin.on('click', function () {
    var phoneNumber = phone_number.val();   //电话号码
    var codeNumber = phone_code.val();  //验证码输入框的值
    if (phoneNumber == '') {
        $('.alertWord').text('手机号码不能为空').show()
        return;
    }
    if (!isPhoneNumber(phoneNumber)) {
        $('.alertWord').text('手机号码有误').show()
        return;
    }
    if (codeNumber == '') {
        $('.alertWord').text('验证码不能为空').show()
        return;
    }
    verification.hide();
    maskBg.hide();
    //清空输入框
    phone_code.val("");
    phone_code_get.html('获取验证码');
    var unionid = getCookie('_unionidpo_');
    var sendObj = {UNIONID: unionid, USERNAME: phoneNumber, VERIFY_CODE: codeNumber, 'LOGIN_SYSTEM': 'web'};
    // 验证-验证码
    $.ajax({
        url: getIp + '/CARNT/UserWeb/signIn.action',
        type: "post",
        dataType: "json",
        data: sendObj,
        success: function (data) {
            if (data.STATUS_CODE == 1) {// 正常返回
                //存储用户登录后的信息
                setCookie('loginkey', data.USER.USER_ID);
                setCookie('name', data.USER.USERNAME);
                setCookie('userName', data.USER.USERNAME);
                if (rollFlag) {
                    $("#lottery #startDraw").trigger("click");
                }
            } else if (data.STATUS_CODE == 2) {// 验证码错误或已过期
                promptBox('验证码错误或已过期！', ' ');
            } else {
                promptBox('验证验证码失败！', ' ');
            }
        }
    });
});

// ----------------------------------------------------------------- web登录部分
function alertVerification() {
    $('.verification').show();
    $('.mask').show();
}
// ------------------------------------------------------------------------------------ web登录检测（不直接调用）
var iLogin = function () {
    if (getCookie('loginkey') && getCookie('userName')) {// 已登录
        return true;
    } else {// 未登录
        return false;
    }
}
// 关闭弹窗
$(".close,.mask,.downloadClose,.close2,.toLogin,.iKnow").on("click", function (event) {
    verification.hide();
    zhongRecord.hide();
    maskBg.hide();
    zhongBox.hide();
    $(".drawRulePages").hide();
    $('.yellowRelative').hide();
    $('.youHaveNot').hide();
    $(".drawRecord").hide();
    $(".drawResult").hide();
    $('.promptBox').hide();
    $('.promptBox1').hide();
})
$('.goRule').on('click', function () {
    $('.yellowRelative').show();
    maskBg.show();
})
// ----------------------------------------------------------------- 显示活动规则
ruleAlert.on("click", function () {
    $(".mask").show();
    $(".drawRulePages").show();
})
// ----------------------------------------------------------------安全锤兑换
$(".safetyHammer").click(function () {
    // 验证公共登录
    if (!commonSignIn())
        return;
    if (_Global_ == 'web') { //支付过直接跳转到核销 未支付跳转到安全锤支付
        location.href = getIp + "/CARNT/jsp/pay/hammerExchange.jsp";
    } else {
        promptBox('请去现场扫码支付', ' ');
    }

})
//小黄人保养，钣喷跳转
$(".minion_left").click(function () {
    openMaintain();
})
$(".minion_right").click(function () {
    openSpray();
})
//兑换5折咖啡券
function exchangeCoffee_1() {
    if (!commonSignIn())
        return;
    $.ajax({
        url: getIp + '/CARNT/loli/hailinzhejuan',
        type: "post",
        dataType: "json",
        data: {
            PHONE: _Global_ == 'web' ? getCookie('userName') : phone,
            SUB_TYPE: 1001,
            ACT_ID: 20171115,
            COMP_ID: '4SCAFEBTA',
            SUBJECT: '5折咖啡券',
            RMK: '5折咖啡券'
        },
        success: function (data) {
            //console.log(data);
            if (data.STATUS_CODE == 1) {
                promptBox('领取成功', ' ');
            } else if (data.STATUS_CODE == 2) {
                promptBox1('您已领取', ' ');
            } else if (data.STATUS_CODE == 15) {
                promptBox('缺少参数', ' ');
            } else {
                alert('服务器有异常');
            }
        }
    });
}
//兑换5元咖啡券
function exchangeCoffee_2() {
    if (!commonSignIn())
        return;
    $.ajax({
        url: getIp + '/CARNT/loli/hailinzhejuan',
        type: "post",
        dataType: "json",
        data: {
            PHONE: _Global_ == 'web' ? getCookie('userName') : phone,
            SUB_TYPE: 1002,
            ACT_ID: 20171115,
            COMP_ID: '4SCAFEBTA',
            SUBJECT: '5元咖啡券',
            RMK: '5元咖啡券'
        },
        success: function (data) {
            if (data.STATUS_CODE == 1) {
                promptBox('领取成功', ' ');
            } else if (data.STATUS_CODE == 2) {
                promptBox1('您已领取', ' ');
            } else if (data.STATUS_CODE == 15) {
                promptBox('缺少参数', ' ');
            } else {
                alert('服务器有异常');
            }
        }
    });
}
//提示分享
function shareFriend() {
    $(".drawResult").hide();
    promptBox('点击右上角分享', ' ');
}
//小黄人
$('.yellowPDD').on('click', function () {
    $('.yellowRelative').show();
    maskBg.show();
})